/*
 * Copyright (c) 2013-2015 Charkey. All rights reserved.
 *
 * This software is the confidential and proprietary information of Charkey.
 * You shall not disclose such Confidential Information and shall use it only
 * in accordance with the terms of the agreements you entered into with Charkey.
 *
 * Charkey MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
 *
 * Charkey SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING,
 * MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
 */

package cn.simastudio.talos.core.service.base.impl;

import cn.simastudio.talos.common.constants.SimaConstants;
import cn.simastudio.talos.core.exception.biz.DataInsertException;
import cn.simastudio.talos.core.mapper.base.LoggingMapper;
import cn.simastudio.talos.core.model.base.Logging;
import cn.simastudio.talos.core.service.base.LoggingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Usage: LoggingServiceImpl
 *
 * @author Charkey
 * @date 2015/7/23 14:28
 */
@SuppressWarnings("SpringJavaAutowiringInspection")
@Service
public class LoggingServiceImpl implements LoggingService {

    @Autowired
    private LoggingMapper loggingMapper;

    @Override
    public Logging logging(Logging logging) {
        int insertRes = loggingMapper.insert(logging);
        if (insertRes != SimaConstants.DEFAULT_UPDATE_COUNT) {
            throw new DataInsertException();
        }
        return logging;
    }
}
